package com.dk.controller;


import com.dk.data.Result;
import com.dk.em.ConstantEnum;
import com.dk.pojo.Role;
import com.dk.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2021-10-29
 */
@RestController
@RequestMapping("roleController")
@Api(value = "角色表文档接口")
public class RoleController {

    @Autowired
    private IRoleService iRoleService;

    @ApiOperation(value = "角色表详细数据展示")
    @GetMapping
    public Result getInfo(){
        List<Role> list = iRoleService.list();
        return Result.bulid(ConstantEnum.SUCCESS).setResult(list);
    }

    @ApiOperation(value = "角色表详细数据增加")
    @PostMapping
    public Result insertRole(Role role,String [] mids){
        boolean b  = iRoleService.insertRole(role,mids);
        return  Result.bulid(ConstantEnum.SUCCESS).setResult(b);
    }

    @ApiOperation(value = "角色表详细数据修改")
    @PutMapping
    public Result update(Role role,String [] mid){
         boolean b = iRoleService.updateRole(role,mid);
         return Result.bulid(ConstantEnum.SUCCESS).setResult(b);
    }

    @ApiOperation(value = "角色表详细数据删除")
    @DeleteMapping
    public Result delete(Long rid){
         boolean b =  iRoleService.deleteByRid(rid);
         return Result.bulid(ConstantEnum.SUCCESS).setResult(b);
    }
}
